<html xmlns:th="http://www.thymeleaf.org" xmlns:layout="http://www.ultraq.net.nz/web/thymeleaf/layout"
      layout:decorator="base/layout.html">


<!-- start: Content -->
<div layout:fragment="content" class="main ">

    <div class="row">
        <div class="col-lg-12">
            <ol class="breadcrumb">
                <li><i class="fa fa-home"></i><a th:href="@{../infoManage/indexTotal}">首页</a></li>
                <li><i class="fa fa-list-alt"></i><a th:href="@{../infoManage/queryInfoManage}">信息发布管理</a></li>
                <li><i class="fa fa-indent"></i>修改信息</li>
            </ol>
        </div>
    </div>

    <div class="row">
        <div class="col-lg-12">
            <div class="panel panel-default">
                <div class="panel-heading">
                    <h2><i class="fa fa-indent red"></i><strong>修改信息</strong></h2>
                </div>
                <div class="panel-body">
                    <form id="modularForm" method="post" enctype="multipart/form-data" class="form-horizontal ">
                        <input id="infoManageId" type="hidden" name="id" th:value="${infoManage.id}"/>

                        <div class="form-group">
                            <label class="col-md-3 control-label" for="text-input">标题</label>
                            <div class="col-md-6">
                                <input type="text" id="title" name="title" class="form-control" placeholder="标题"
                                       th:value="${infoManage.title}" required>
                                <span class="help-block">请修改标题(必填)</span>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-md-3 control-label" for="text-input">内容</label>
                            <div class="col-md-9">
                                   <textarea class="layui-textarea" id="introduction" style="display: none" th:text="${infoManage.introduction}"required>


					                </textarea>
                            </div>
                        </div>
                        <br>
                </div>
                <div class="panel-footer">
                    <button id="submitBtn" type="submit" class="btn btn-sm btn-success"><i
                            class="fa fa-dot-circle-o"></i> 保存
                    </button>
                    <button type="button" class="btn btn-sm btn-success" onclick="history.back()"><i
                            class="fa fa-dot-circle-o"></i> 返回
                    </button>
                </div>
                </form>
            </div>
        </div>
    </div><!--/.row-->
    <script>
        var layedit, index;
        $(document).ready(function () {

            var pro = window.location.protocol;
            var host = window.location.host;
            var domain = pro + "//" + host;

            layui.use(['layedit', 'upload'], function () {
                layedit = layui.layedit;
                layedit.set({
                    uploadImage: {
                        url: 'uploadLayuiFile?domain=' + domain,
                        type: 'post'
                    }
                });
                index = layedit.build('introduction');
            });

        })


        $("#modularForm").validate({

            submitHandler: function (form) {

                var formdata = {};


                var content=layedit.getContent(index);

                if (content.length==0||$.trim(content)==""){
                    layer.msg("请输入内容")
                }else{
                    formdata.introduction = layedit.getContent(index);
                    $("#modularForm").ajaxSubmit(
                        {
                            url: 'infoManageUpdate',
                            type: 'post',
                            data :formdata,
                            success: function (data) {

                                layer.msg("添加成功");
                                setTimeout(function () {
                                    window.location = ("queryInfoManage")
                                }, 1500);
                            }
                            //clearForm: false,//禁止清楚表单
                            //resetForm: false //禁止重置表单
                        });
                }
            }
        })


    </script>
</div>
